<?php
//后台路由

//路由分组
//prefix是uri的前缀
//namespace是action的前缀
//as是别名的前缀
Route::group(['prefix'=>'admin','namespace'=>'Admin','as' => 'admin.'], function() {
    //登陆显示(别名 admin.login)
    Route::get('login' ,'LoginController@index')->name('login');
    //登陆处理
    Route::post('login' ,'LoginController@login')->name('login');

    Route::group(['middleware'=> ['ckadminlogin']], function() {
        Route::get('index' ,'IndexController@index')->name('index');
        //后台首页欢迎页面显示(内嵌iframe欢迎页面)
        Route::get('welcome' ,'IndexController@welcome')->name('welcome');
        //Route::get('welcome' ,'IndexController@welcome')->name('admin.welcome')->middleware(['ckadminlogin']);
        //退出
        Route::get('logout' ,'IndexController@logout')->name('logout');

        //用户列表:展示
        Route::get('user/index' ,'UserController@index')->name('user.index');
        //添加用户:展示
        Route::get('user/add' ,'UserController@create')->name('user.create');
        //添加用户:处理
        Route::post('user/add' ,'UserController@store')->name('user.store');
        //发送邮件
        Route::get('user/email',function () {
            //发送文本邮件
//            \Mail::raw('邮件具体内容', function (\Illuminate\Mail\Message $message) {
//                //dump(func_get_args());
//
//                //发给谁
//                $message->to('c15622292256@163.com');
//                //主题
//                $message->subject('纯文本邮件主题');
//                //from
//                //.env的MAIL_FROM_NAME=laravelkevin
//            });
            //富文本邮件：传参['user' => '张三']结构后传给adduser.blade.php
//            \Mail::send('mail.adduser', ['user' => '张三'], function(\Illuminate\Mail\Message $message) {
//                $message->subject('富文本邮件主题');
//                $message->to('2895456075@qq.com');
//            });
        });
        //删除用户 restful
        Route::delete('user/del/{id}' ,'UserController@del')->name('user.del');
        //还原已软删除用户
        Route::get('user/restore/{id}' ,'UserController@restore')->name('user.restore');
        //全选删除
        Route::delete('user/delall' ,'UserController@delall')->name('user.delall');
        //修改用户:展示
        Route::get('user/edit/{id}' ,'UserController@edit')->name('user.edit');
        //修改用户:处理
        Route::put('user/edit/{id}' ,'UserController@update')->name('user.edit');

        //给用户分配角色
        Route::match(['get', 'post'], 'user/role/{user}', 'UserController@role')->name('user.role');

        //角色管理
        //Route::resource('role' ,'RoleController', ['as' => 'admin']); 单个as用法
        //修改角色拥有的节点(权限)：展示
        Route::get('role/node/{role}' ,'RoleController@node')->name('role.node');
        //修改角色拥有的节点(权限): 处理
        Route::post('role/node/{role}' ,'RoleController@nodeSave')->name('role.node');
        //朦胧的路由写在最下面，具体的路由写在上面
        //资源路由
        Route::resource('role' ,'RoleController');
// Method    | URI                     | Name               | Action                                             | Middleware
// GET|HEAD  | admin/role              | admin.role.index   | App\Http\Controllers\Admin\RoleController@index    | web,ckadminlogin |
// POST      | admin/role              | admin.role.store   | App\Http\Controllers\Admin\RoleController@store    | web,ckadminlogin |
// GET|HEAD  | admin/role/create       | admin.role.create  | App\Http\Controllers\Admin\RoleController@create   | web,ckadminlogin |
// DELETE    | admin/role/{role}       | admin.role.destroy | App\Http\Controllers\Admin\RoleController@destroy  | web,ckadminlogin |
// PUT|PATCH | admin/role/{role}       | admin.role.update  | App\Http\Controllers\Admin\RoleController@update   | web,ckadminlogin |
// GET|HEAD  | admin/role/{role}       | admin.role.show    | App\Http\Controllers\Admin\RoleController@show     | web,ckadminlogin |
// GET|HEAD  | admin/role/{role}/edit  | admin.role.edit    | App\Http\Controllers\Admin\RoleController@edit     | web,ckadminlogin

        //节点管理
        Route::resource('node' ,'NodeController');

        //文章管理异步上传(必须写在文章管理资源路由上面，因为如果写在下面，admin/article/upfile会被资源理由的admin/article/{article}匹配上)
        Route::post('article/upfile', 'ArticleController@upfile')->name('article.upfile');
        //文章管理资源路由
        Route::resource('article' ,'ArticleController');
//E:\main\work\php\laravel\zfw>php artisan route:list | findstr article
//POST          | admin/article               | admin.article.store   | App\Http\Controllers\Admin\ArticleController@store   | web,ckadminlogin |
//GET|HEAD      | admin/article    文章列表     | admin.article.index   | App\Http\Controllers\Admin\ArticleController@index   | web,ckadminlogin |
//GET|HEAD      | admin/article/create         | admin.article.create  | App\Http\Controllers\Admin\ArticleController@create  | web,ckadminlogin |
//DELETE        | admin/article/{article}      | admin.article.destroy | App\Http\Controllers\Admin\ArticleController@destroy | web,ckadminlogin |
//GET|HEAD      | admin/article/{article}      | admin.article.show    | App\Http\Controllers\Admin\ArticleController@show    | web,ckadminlogin |
//PUT|PATCH     | admin/article/{article}      | admin.article.update  | App\Http\Controllers\Admin\ArticleController@update  | web,ckadminlogin |
//GET|HEAD      | admin/article/{article}/edit | admin.article.edit    | App\Http\Controllers\Admin\ArticleController@edit    | web,ckadminlogin |

        //房源属性
        Route::post('fangattr/upfile', 'FangAttrController@upfile')->name('fangattr.upfile');
        Route::resource('fangattr' ,'FangAttrController');
//POST          | admin/fangattr                 | admin.fangattr.store   | App\Http\Controllers\Admin\FangAttrController@store   | web,ckadminlogin |
//GET|HEAD      | admin/fangattr                 | admin.fangattr.index   | App\Http\Controllers\Admin\FangAttrController@index   | web,ckadminlogin |
//GET|HEAD      | admin/fangattr/create          | admin.fangattr.create  | App\Http\Controllers\Admin\FangAttrController@create  | web,ckadminlogin |
//DELETE        | admin/fangattr/{fangattr}      | admin.fangattr.destroy | App\Http\Controllers\Admin\FangAttrController@destroy | web,ckadminlogin |
//GET|HEAD      | admin/fangattr/{fangattr}      | admin.fangattr.show    | App\Http\Controllers\Admin\FangAttrController@show    | web,ckadminlogin |
//PUT|PATCH     | admin/fangattr/{fangattr}      | admin.fangattr.update  | App\Http\Controllers\Admin\FangAttrController@update  | web,ckadminlogin |
//GET|HEAD      | admin/fangattr/{fangattr}/edit | admin.fangattr.edit    | App\Http\Controllers\Admin\FangAttrController@edit    | web,ckadminlogin |

        //房东管理
        //导出execl
        Route::get('fangowner/exports', 'FangOwnerController@exports')->name('fangowner.exports');
        //文件上传
        Route::post('fangowner/upfile', 'FangOwnerController@upfile')->name('fangowner.upfile');
        //删除已上传的房东身份证照片
        Route::get('fangowner/delfile', 'FangOwnerController@delfile')->name('fangowner.delfile');
        Route::resource('fangowner' ,'FangOwnerController');
    });


});
